﻿using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using Windows.Storage;

namespace OMR.Database.WinRTTests
{
    [TestClass]
    public class StoragePerfTests
    {
        const int LoadCount = 100;

        [TestInitialize]
        public void InitStorage()
        {
        }

        [TestMethod()]
        public void RoamingValueSettingCreationTest()
        {
            for (int i = 0; i < LoadCount; i++)
            {
                ApplicationData.Current.RoamingSettings.Values.Add("r" + i.ToString(), i);
            }
        }

        [TestMethod()]
        public void LocalValueCreationTest()
        {
            for (int i = 0; i < LoadCount; i++)
            {
                ApplicationData.Current.LocalSettings.Values.Add("t" + i.ToString(), i);
            }
        }

        [TestMethod()]
        public void LocalFolderCreationTest()
        {
            for (int i = 0; i < LoadCount; i++)
            {
                ApplicationData.Current.LocalFolder.CreateFileAsync(i.ToString());
            }
        }

        [TestMethod()]
        public void RoamingFolderCreationTest()
        {
            for (int i = 0; i < LoadCount; i++)
            {
                ApplicationData.Current.RoamingFolder.CreateFileAsync(i.ToString());
            }
        }

        [TestCleanup]
        public void CleanUp()
        {
            ApplicationData.Current.RoamingSettings.Values.Clear();
            ApplicationData.Current.LocalSettings.Values.Clear();

            ApplicationData.Current.LocalFolder.DeleteAsync();
        }
    }
}
